home *** CD-ROM | disk | FTP | other *** search
- /* clock.c Turbo C Bible functions, p. 329 */
- #include <stdio.h>
- #include <time.h>
- main()
- {
- unsigned i, tused, count=10000;
- double a, b, c, d;
- clock_t ticksnow;
- for(i = 0; i < count; i++)
- {
- a = (double)(i-1);
- b = (double)(i+1);
- c = (double)(i*i);
- d = a*b - c;
- }
- if ((ticksnow = clock()) == (clock_t)-1)
- /* Get current clock ticks by calling "clock" */
- {
- printf("Processor time not available!\n");
- abort();
- }
- tused = (unsigned) ticksnow / CLK_TCK;
- /* Convert processor time to seconds. Use CLK_TCK */
- printf("10,000 loops ran for %u seconds\n", tused);
- }